package com.yic.module.device.dal.mysql.resume;

import java.util.*;

import com.yic.framework.common.pojo.PageResult;
import com.yic.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.yic.framework.mybatis.core.mapper.BaseMapperX;
import com.yic.module.device.dal.dataobject.resume.ResumeDO;
import org.apache.ibatis.annotations.Mapper;
import com.yic.module.device.controller.admin.resume.vo.*;

/**
 * 设备履历 Mapper
 *
 * @author 系统管理员
 */
@Mapper
public interface ResumeMapper extends BaseMapperX<ResumeDO> {

    default PageResult<ResumeDO> selectPage(ResumePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ResumeDO>()
                .eqIfPresent(ResumeDO::getDeviceId, reqVO.getDeviceId())
                .eqIfPresent(ResumeDO::getType, reqVO.getType())
                .eqIfPresent(ResumeDO::getSourceId, reqVO.getSourceId())
                .eqIfPresent(ResumeDO::getUserId, reqVO.getOperateUser())
                .betweenIfPresent(ResumeDO::getOperateTime, reqVO.getOperateTime())
                .betweenIfPresent(ResumeDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(ResumeDO::getId));
    }

    default List<ResumeDO> selectList(ResumeExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<ResumeDO>()
                .eqIfPresent(ResumeDO::getDeviceId, reqVO.getDeviceId())
                .eqIfPresent(ResumeDO::getType, reqVO.getType())
                .eqIfPresent(ResumeDO::getSourceId, reqVO.getSourceId())
                .eqIfPresent(ResumeDO::getUserId, reqVO.getOperateUser())
                .betweenIfPresent(ResumeDO::getOperateTime, reqVO.getOperateTime())
                .betweenIfPresent(ResumeDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(ResumeDO::getId));
    }

    default int deleteBySourceId(Long id, Integer deviceResumeType) {
        return delete(new LambdaQueryWrapperX<ResumeDO>()
                .eq(ResumeDO::getSourceId, id)
                .eq(ResumeDO::getType, deviceResumeType));
    }
}
